<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="会员姓名" prop="buyerName">
        <el-input
          v-model="queryParams.buyerName"
          placeholder="请输入会员姓名"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="订单ID" prop="orderId">
        <el-input
          v-model="queryParams.orderId"
          placeholder="请输入订单ID"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="订单编号" prop="orderNo">
        <el-input
          v-model="queryParams.orderNo"
          placeholder="请输入订单号"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>

      <el-form-item label="订单状态" prop="orderStatus">
        <el-select
          v-model="queryParams.orderStatus"
          placeholder="订单状态"
          clearable
          style="width: 200px"
        >
          <el-option
            v-for="dict in order_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="支付状态" prop="paymentStatus">
        <el-select
          v-model="queryParams.paymentStatus"
          placeholder="支付状态"
          clearable
          style="width: 200px"
        >
          <el-option
            v-for="dict in order_payment_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="配送状态" prop="expressStatus">
        <el-select
          v-model="queryParams.expressStatus"
          placeholder="配送状态"
          clearable
          style="width: 200px"
        >
          <el-option
            v-for="dict in order_express_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="客户名称" prop="fullName">
        <el-input
          v-model="queryParams.fullName"
          placeholder="请输入客户名称"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>

      <el-form-item label="客户简称" prop="companyName">
        <el-input
          v-model="queryParams.companyName"
          placeholder="请输入客户简称"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="商品名称" prop="productName">
        <el-input
          v-model="queryParams.productName"
          placeholder="请输入商品名称"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="加急状态" prop="jiajiId">
        <el-select
          v-model="queryParams.jiajiId"
          placeholder="加急状态"
          clearable
          style="width: 200px"
        >
          <el-option
            v-for="dict in jiajiList"
            :key="dict.processId"
            :label="dict.name"
            :value="dict.processId"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="导出状态" prop="exportStatus">
        <el-select
          v-model="queryParams.exportStatus"
          placeholder="导出状态"
          clearable
          style="width: 200px"
        >
          <el-option
            v-for="dict in order_export_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="支付完成时间" prop="payedTimes" label-width="100">
        <el-date-picker
          v-model="queryParams.payedTimes"
          type="datetimerange"
          :picker-options="pickerOptions"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          :default-time="[
            new Date(2023, 2, 1, 0, 0, 0, 0),
            new Date(2023, 2, 5, 23, 59, 59, 0),
          ]"
          align="right"
        >
        </el-date-picker>
      </el-form-item>
      <el-form-item label="订单创建时间" prop="createTimes" label-width="100">
        <el-date-picker
          v-model="queryParams.createTimes"
          type="datetimerange"
          :picker-options="pickerOptions"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          :default-time="[
            new Date(2023, 2, 1, 0, 0, 0, 0),
            new Date(2023, 2, 5, 23, 59, 59, 0),
          ]"
          align="right"
        >
        </el-date-picker>
      </el-form-item>

      <el-form-item v-if="isManage" label="区域代理" prop="deptId">
        <el-select
          v-model="queryParams.deptId"
          placeholder="区域代理"
          clearable
          style="width: 200px"
        >
          <el-option
            v-for="dict in deptList"
            :key="dict.deptId"
            :label="dict.deptName"
            :value="dict.deptId"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="顾客姓名" prop="orderChannelUserName">
        <el-input
          v-model="queryParams.orderChannelUserName"
          placeholder="请输入顾客姓名"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item
        label="发货完成时间"
        prop="orderExpressCreateTimes"
        label-width="100"
      >
        <el-date-picker
          v-model="queryParams.orderExpressCreateTimes"
          type="datetimerange"
          :picker-options="pickerOptions"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          :default-time="[
            new Date(2023, 2, 1, 0, 0, 0, 0),
            new Date(2023, 2, 5, 23, 59, 59, 0),
          ]"
          align="right"
        >
        </el-date-picker>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="search" size="mini" @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <!-- <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['yanjing:order:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['yanjing:order:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['yanjing:order:remove']"
          >删除</el-button
        >
      </el-col> -->
      <el-col :span="1.5">
        <!-- <el-button
          type="warning"
          plain
          icon="download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['yanjing:order:export']"
          >导出</el-button
        > -->
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="download"
          size="mini"
          @click="handleProductExport"
          v-hasPermi="['yanjing:order:handleProductExport']"
          >导出生产单</el-button
        >
      </el-col>
      <right-toolbar
        v-model:showSearch.sync="showSearch"
        @queryTable="getList"
        :columns="columns"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="orderList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column
        type="selection"
        :selectable="isCheckboxDisabled"
        width="55"
        align="center"
      />
      <el-table-column label="序号" type="index" width="60"></el-table-column>
      <el-table-column label="客户简称" align="center" prop="companyName" />
      <el-table-column label="会员姓名" align="center" prop="buyerName" />
      <el-table-column
        label="订单编号"
        align="center"
        prop="orderNo"
        width="110"
      />
      <el-table-column
        v-if="columns[0].visible"
        label="商品名称"
        align="center"
        prop="productName"
      />
      <el-table-column
        v-if="columns[1] && columns[1].visible"
        label="订单金额"
        align="center"
        prop="orderPay"
        width="80"
      >
        <template #default="scope">
          {{ (Math.round(scope.row.orderPay) / 100).toFixed(2) }}
        </template>
      </el-table-column>
      <el-table-column
        v-if="columns[2] && columns[2].visible"
        label="应付金额"
        align="center"
        prop="oughtPay"
        width="80"
      >
        <template #default="scope">
          {{ (Math.round(scope.row.oughtPay) / 100).toFixed(2) }}
        </template>
      </el-table-column>
      <el-table-column
        v-if="columns[3] && columns[3].visible"
        label="实收金额"
        align="center"
        prop="actualPay"
        width="80"
      >
        <template #default="scope">
          {{ (Math.round(scope.row.actualPay) / 100).toFixed(2) }}
        </template>
      </el-table-column>
      <!-- <el-table-column label="订单状态" align="center" prop="orderStatus">
        <template #default="scope">
          <dict-tag :options="order_status" :value="scope.row.orderStatus" />
        </template>
      </el-table-column> -->
      <el-table-column
        label="支付状态"
        align="center"
        prop="paymentStatus"
        width="80"
      >
        <template #default="scope">
          <dict-tag
            :options="order_payment_status"
            :value="scope.row.paymentStatus"
          />
        </template>
      </el-table-column>
      <el-table-column
        label="配送状态"
        align="center"
        prop="expressStatus"
        width="80"
      >
        <template #default="scope">
          <dict-tag
            :options="order_express_status"
            :value="scope.row.expressStatus"
          />
        </template>
      </el-table-column>
      <el-table-column
        label="加急状态"
        align="center"
        prop="jiajiName"
        width="80"
      />
      <el-table-column
        label="导出状态"
        align="center"
        prop="exportStatus"
        width="80"
      >
        <template #default="scope">
          <dict-tag
            :options="order_export_status"
            :value="scope.row.exportStatus"
          />
        </template>
      </el-table-column>
      <el-table-column
        label="下单时间"
        align="center"
        prop="createTime"
        width="160"
      />
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template #default="scope">
          <el-button
            size="mini"
            type="text"
            icon="View"
            @click="handleView(scope.row, scope.index)"
            >详细</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="View"
            @click="showProduceBill(scope.row, scope.index)"
            v-hasPermi="['yanjing:order:handleProductExport']"
            >生产单</el-button
          >
          <!-- <el-button
            size="mini"
            type="text"
            icon="edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['yanjing:order:edit']"
            >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['yanjing:order:remove']"
            >删除</el-button
          > -->
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      v-model:page.sync="queryParams.pageNum"
      v-model:limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改对话框 -->
    <el-dialog :title="title" v-model="open" width="1350px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="130px">
        <div style="pointer-events: none">
          <el-form-item class="zdy" label="客户信息" prop="companyName">
            <el-input
              style="width: 81%"
              type="textarea"
              v-model="companyAllInfo"
            />
          </el-form-item>
          <el-row>
            <el-col :span="6">
              <el-form-item class="zdy" label="下单会员名称" prop="buyerName">
                <el-input v-model="form.buyerName" readonly="readonly" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item class="zdy" label="订单编号" prop="orderNo">
                <el-input v-model="form.orderNo" readonly="readonly" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item class="zdy" label="下单时间" prop="createTime">
                <el-input v-model="form.createTime" readonly="readonly" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item class="zdy" label="订单状态" prop="orderStatus">
                <el-select
                  v-model="form.orderStatus"
                  clearable
                  readonly="readonly"
                >
                  <el-option
                    v-for="item in order_status"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item class="zdy" label="支付状态" prop="paymentStatus">
                <el-select v-model="form.paymentStatus" clearable>
                  <el-option
                    v-for="item in order_payment_status"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item class="zdy" label="支付时间" prop="payedTime">
                <el-input v-model="form.payedTime" placeholder="" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item class="zdy" label="配送状态" prop="expressStatus">
                <el-select
                  v-model="form.expressStatus"
                  placeholder=""
                  clearable
                >
                  <el-option
                    v-for="item in order_express_status"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item class="zdy" label="签收时间" prop="completeTime">
                <el-input v-model="form.completeTime" placeholder="" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item class="zdy" label="所选快递" prop="expressName">
                <el-input v-model="form.expressName" placeholder="" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                class="zdy"
                label="订单产品金额"
                prop="orderPayYuan"
              >
                <el-input v-model="form.orderPayYuan" placeholder="" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item class="zdy" label="应付金额" prop="oughtPayYuan">
                <el-input v-model="form.oughtPayYuan" placeholder="" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item class="zdy" label="实付金额" prop="actualPayYuan">
                <el-input v-model="form.actualPayYuan" placeholder="" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item
                class="zdy"
                label="退款发起者"
                prop="refundUserName"
              >
                <el-input v-model="form.refundUserName" placeholder="" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item class="zdy" label="退款状态" prop="refundStatusZh">
                <el-input v-model="form.refundStatusZh" placeholder="" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item class="zdy" label="退款金额" prop="refundPayYuan">
                <el-input v-model="form.refundPayYuan" placeholder="" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item class="zdy" label="退款时间" prop="refundTime">
                <el-input v-model="form.refundTime" placeholder="" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item class="zdy" label="委托加工" prop="jiagongStatusZh">
                <el-input v-model="form.jiagongStatusZh" placeholder="" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                class="zdy"
                label="委托加工金额"
                prop="jiagongPayYuan"
              >
                <el-input v-model="form.jiagongPayYuan" placeholder="" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                class="zdy"
                label="顾客姓名"
                prop="orderChannelUserName"
              >
                <el-input v-model="form.orderChannelUserName" placeholder="" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item class="zdy" label="委托信息" prop="jiagongMemo">
                <el-input v-model="form.jiagongMemo" placeholder="" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item class="zdy" label="美薄加工" prop="meiboStatusZh">
                <el-input v-model="form.meiboStatusZh" placeholder="" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                class="zdy"
                label="美薄加工金额"
                prop="meiboPayYuan"
              >
                <el-input v-model="form.meiboPayYuan" placeholder="" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item class="zdy" label="加急方式" prop="jiajiName">
                <el-input v-model="form.jiajiName" placeholder="" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item class="zdy" label="加急金额" prop="jiajiPayYuan">
                <el-input v-model="form.jiajiPayYuan" placeholder="" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item class="zdy" label="按样染色" prop="ranseStatusZh">
                <el-input v-model="form.ranseStatusZh" placeholder="" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item class="zdy" label="按样染色方式" prop="ranseTypeZh">
                <el-input v-model="form.ranseTypeZh" placeholder="" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item class="zdy" label="染色色号" prop="ranseNo">
                <el-input v-model="form.ranseNo" placeholder="" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                class="zdy"
                label="按样染色金额"
                prop="ransePayYuan"
              >
                <el-input v-model="form.ransePayYuan" placeholder="" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item class="zdy" label="UV420防蓝光" prop="bianseColor">
                <el-input v-model="form.bianseColor" placeholder="" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item class="zdy" label="防蓝光金额" prop="biansePayYuan">
                <el-input v-model="form.biansePayYuan" placeholder="" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item class="zdy" label="个性刻字" prop="keziName">
                <el-input v-model="form.keziName" placeholder="" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item class="zdy" label="个性刻字金额" prop="keziPayYuan">
                <el-input v-model="form.keziPayYuan" placeholder="" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item
                class="zdy"
                label="附加棱镜金额"
                prop="lengjingPayYuan"
              >
                <el-input v-model="form.lengjingPayYuan" placeholder="" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                class="zdy"
                label="来样染色金额"
                prop="laiyangPayYuan"
              >
                <el-input v-model="form.laiyangPayYuan" placeholder="" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                class="zdy"
                label="等像镜金额"
                prop="dengxiangPayYuan"
              >
                <el-input v-model="form.dengxiangPayYuan" placeholder="" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                class="zdy"
                label="超光度金额"
                prop="chaoguangduPayYuan"
              >
                <el-input v-model="form.chaoguangduPayYuan" placeholder="" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item class="zdy" label="特殊工艺" prop="teshuPayYuan">
                <el-input v-model="form.teshuPayYuan" placeholder="" />
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item
                class="zdy"
                label="特殊工艺金额"
                prop="teshuStatusZh"
              >
                <el-input v-model="form.teshuStatusZh" placeholder="" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-form-item class="zdy" label="订单备注" prop="memo">
            <el-input
              style="width: 81%"
              type="textarea"
              v-model="form.memo"
              placeholder=""
            />
          </el-form-item>
        </div>
      </el-form>
      <div class="styled-div">产品信息</div>
      <el-table :data="productList">
        <el-table-column type="selection" width="55" align="center" />
        <el-table-column label="序号" type="index" width="60"></el-table-column>
        <el-table-column label="产品名称" align="center" min-width="400%">
          <template #default="scope">
            <div>【{{ scope.row.productId }}】{{ scope.row.productName }}</div>
          </template>
        </el-table-column>
        <el-table-column label="市场价" align="center" prop="listPriceStr" />
        <el-table-column label="数量" align="center" prop="quantity" />
        <el-table-column label="左眼数量" align="center" prop="leftQuantity" />
        <el-table-column label="右眼数量" align="center" prop="rightQuantity" />
        <el-table-column label="总金额" align="center" prop="totalPriceStr" />
      </el-table>

      <div class="styled-div">其他信息</div>

      <el-tabs
        v-model="activeName"
        type="border-card"
        @tab-click="handleTabClick"
      >
        <el-tab-pane label="支付记录" name="first">
          <el-table :data="paymentList">
            <el-table-column type="selection" width="55" align="center" />
            <el-table-column
              label="序号"
              type="index"
              width="60"
            ></el-table-column>
            <el-table-column
              label="交易流水号"
              align="center"
              prop="paymentTradeNo"
            />
            <el-table-column label="银行渠道" align="center" prop="gateway" />
            <el-table-column
              label="银行流水号"
              align="center"
              prop="gatewayTradeNo"
            />
            <el-table-column
              label="交易金额"
              align="center"
              prop="amountYuan"
            />
            <el-table-column label="交易状态" align="center" prop="statusZh" />
            <el-table-column
              label="交易创建时间"
              align="center"
              prop="createTime"
            />
            <el-table-column
              label="交易完成时间"
              align="center"
              prop="callbackTime"
            />
          </el-table>
        </el-tab-pane>
        <el-tab-pane label="收货地址" name="second">
          <el-table :data="orderAddressList">
            <el-table-column type="selection" width="55" align="center" />
            <el-table-column
              label="序号"
              type="index"
              width="60"
            ></el-table-column>
            <el-table-column label="收货人姓名" align="center" prop="recName" />
            <el-table-column
              label="收货人电话"
              align="center"
              prop="recMobile"
            />
            <el-table-column
              label="收货人地址"
              align="center"
              prop="recAddress"
            />
          </el-table>
        </el-tab-pane>
        <el-tab-pane label="物流信息" name="third">
          <el-table :data="orderExpressList">
            <el-table-column type="selection" width="55" align="center" />
            <el-table-column
              label="序号"
              type="index"
              width="60"
            ></el-table-column>
            <el-table-column
              label="物流公司"
              align="center"
              prop="expressName"
            />
            <el-table-column label="物流编号" align="center" prop="expressNo" />
            <el-table-column label="物流状态" align="center" prop="status">
              <template #default="scope">
                <dict-tag
                  :options="order_express_status"
                  :value="scope.row.status"
                />
              </template>
            </el-table-column>
            <el-table-column label="签收人" align="center" prop="accept" />
            <el-table-column label="签收人电话" align="center" prop="phone" />
            <el-table-column label="签收地址" align="center" prop="address" />
            <el-table-column
              label="发货时间"
              align="center"
              prop="createTime"
            />
          </el-table>
          <el-button
            type="primary"
            plain
            icon="plus"
            size="mini"
            @click="refreshExpressInfo()"
            >刷新物流信息</el-button
          >
        </el-tab-pane>
        <el-tab-pane label="右/左眼参数" name="fourth">
          <div>
            <span
              style="
                display: block;
                float: left;
                height: 25px;
                margin: 2px 2px;
                background-color: #eef0f4;
              "
            >
              产品名称：{{ productName }}【右眼】
            </span>
          </div>
          <br />
          <br />
          <div v-for="item in patternOneRightList" :key="item.id">
            <span
              style="
                display: block;
                width: 18%;
                float: left;
                height: 25px;
                margin: 2px 2px;
              "
            >
              {{ item.patternName }}: {{ item.patternValue }}
              {{ item.patternUnit }}
            </span>
          </div>
          <br />
          <br />
          <br />
          <br />
          <div>
            <span
              style="
                display: block;
                float: left;
                height: 25px;
                margin: 2px 2px;
                background-color: #eef0f4;
              "
            >
              产品名称：{{ productName }}【左眼】
            </span>
          </div>
          <br />
          <br />
          <div v-for="item in patternOneLeftList" :key="item.id">
            <span
              style="
                display: block;
                width: 18%;
                float: left;
                height: 25px;
                margin: 2px 2px;
              "
            >
              {{ item.patternName }}: {{ item.patternValue }}
              {{ item.patternUnit }}
            </span>
          </div>
          <br />
          <br />
        </el-tab-pane>
      </el-tabs>
      <br />
      <br />
      <div slot="footer" class="dialog-footer" align="center">
        <el-button v-if="isDetail" type="primary" @click="submitForm"
          >确 定</el-button
        >
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 订货单信息 -->
    <el-dialog
      title="订货单信息"
      v-model="isShowProduceBill"
      width="1050px"
      append-to-body
    >
      <table
        style="font-size: 14px"
        cellspacing="1"
        cellpadding="4"
        border="0"
        align="center"
        id="cartTable"
        width="760"
      >
        <tr bgcolor="#FFFFFF" height="25px">
          <td align="left" colspan="4">
            <!-- <input type="button" id="button_print" value="打印" onclick="javascript:printitTO('div1')">  -->
            <!-- <el-button type="primary" @click="print" v-print="'#printTest'">打印</el-button> -->
            <el-button @click="printTable">打印</el-button>
          </td>
        </tr>
      </table>

      <div class="con_right" id="printTest">
        <div class="con_rightCon">
          <table
            style="font-size: 14px"
            cellspacing="1"
            cellpadding="4"
            border="0"
            align="center"
            id="cartTable"
            width="760"
          >
            <tr bgcolor="#FFFFFF" height="28px">
              <td
                align="center"
                colspan="6"
                style="font-weight: 600; font-size: 20px"
              >
                上海吾度睛制科技有限公司·订货单
              </td>
            </tr>

            <tr bgcolor="#FFFFFF" height="25px"></tr>

            <tr bgcolor="#FFFFFF" height="28px">
              <td width="120px" bgcolor="#f4f4f4" align="right">订单编号：</td>
              <td width="260px" align="left">{{ productBillInfo.orderNo }}</td>
              <td width="120px" bgcolor="#f4f4f4" align="right">订货时间：</td>
              <td width="260px" align="left">
                {{ productBillInfo.orderTime }}
              </td>
            </tr>
            <tr bgcolor="#FFFFFF" height="28px">
              <td width="120px" bgcolor="#f4f4f4" align="right">客户名称：</td>
              <td width="260px" align="left">
                {{ productBillInfo.companyName }}
              </td>
              <td width="120px" bgcolor="#f4f4f4" align="right">
                客户订单编号：
              </td>
              <td width="260px" align="left">
                {{ productBillInfo.channelNo }}
              </td>
            </tr>

            <tr bgcolor="#FFFFFF" height="28px">
              <td width="120px" bgcolor="#f4f4f4" align="right">联系人：</td>
              <td width="260px" align="left">{{ productBillInfo.linkName }}</td>
              <td width="120px" bgcolor="#f4f4f4" align="right">顾客姓名：</td>
              <td width="260px" align="left">
                {{ productBillInfo.channelUserName }}
              </td>
            </tr>

            <tr bgcolor="#FFFFFF" height="28px">
              <td width="120px" bgcolor="#f4f4f4" align="right">品名：</td>
              <td width="260px" align="left">
                {{ productBillInfo.productName }}
              </td>
              <td width="120px" bgcolor="#f4f4f4" align="right">镜架型号：</td>
              <td width="260px" align="left">
                {{ productBillInfo.jingjiaNo }}
              </td>
            </tr>
            <tr bgcolor="#FFFFFF" height="28px">
              <td width="120px" bgcolor="#f4f4f4" align="right">发货地址：</td>
              <td align="left" colspan="3">{{ productBillInfo.address }}</td>
            </tr>
            <tr bgcolor="#FFFFFF" height="28px">
              <td width="120px" bgcolor="#f4f4f4" align="right">备注：</td>
              <td align="left" colspan="5">{{ productBillInfo.orderMemo }}</td>
            </tr>
          </table>

          <div style="height: 5px"></div>
          <table
            style="font-size: 14px"
            cellspacing="1"
            cellpadding="4"
            border="0"
            bgcolor="#333333"
            width="760"
            align="center"
          >
            <tbody>
              <tr bgcolor="#f4f4f4" height="28px">
                <th style="white-space: nowrap" align="center">R/L</th>
                <th style="white-space: nowrap" align="center">数量</th>
                <th style="white-space: nowrap" align="center">直径</th>
                <th style="white-space: nowrap" align="center">球镜</th>
                <th style="white-space: nowrap" align="center">柱镜</th>
                <th style="white-space: nowrap" align="center">轴位</th>
                <th style="white-space: nowrap" align="center">下加光</th>
                <th style="white-space: nowrap" align="center">委托加工</th>
                <th style="white-space: nowrap" align="center">防蓝光</th>
                <th style="white-space: nowrap" align="center">瞳距</th>
                <th style="white-space: nowrap" align="center">瞳高</th>
                <th style="white-space: nowrap" align="center">通道</th>
                <th style="white-space: nowrap" align="center">棱镜</th>
                <th style="white-space: nowrap" align="center">变色</th>
              </tr>
              <tr
                v-for="(item, index) in productBillInfo.productList"
                :key="index"
                bgcolor="#ffffff"
              >
                <td align="center">{{ item.site }}</td>
                <td align="center">{{ item.siteQuantity }}</td>
                <td align="center">{{ item.zhijing }}</td>
                <td align="center">{{ item.qiujing }}</td>
                <td align="center">{{ item.zhujing }}</td>
                <td align="center">{{ item.zhouwei }}</td>
                <td align="center">{{ item.xiajiaguang }}</td>
                <td align="center">{{ item.weituo }}</td>
                <td align="center">{{ item.huanxiang }}</td>
                <td align="center">{{ item.tongju }}</td>
                <td align="center">{{ item.tonggao }}</td>
                <td align="center">{{ item.tongdao }}</td>
                <td align="center">{{ item.lengjing }}</td>
                <td align="center">{{ item.bianse }}</td>
              </tr>
            </tbody>
          </table>

          <div style="height: 10px"></div>
          <table
            style="font-size: 14px"
            cellspacing="1"
            cellpadding="4"
            border="0"
            align="center"
            id="cartTable"
            width="760"
          >
            <tr bgcolor="#FFFFFF" height="28px">
              <td width="120px" align="right">个性刻字：</td>
              <td width="260px" align="left">
                {{ defaultText(productBillInfo.kezi, 2) }}
              </td>
              <td width="120px" align="right">美薄：</td>
              <td width="260px" align="left">{{ productBillInfo.meibo }}</td>

              <td width="120px" align="right">按样染色：</td>
              <td width="260px" align="left">
                {{ defaultText(productBillInfo.ranse, 2) }}
              </td>
              <!-- <td width="120px" align="right">防蓝光：</td>
              <td width="260px" align="left">
                {{ defaultText(productBillInfo.productList[0].huanxiang) }}
              </td> -->
            </tr>
            <tr bgcolor="#FFFFFF" height="28px">
              <td width="120px" align="right">色号：</td>
              <td width="260px" align="left">
                {{ defaultText(productBillInfo.ranseNo, 2) }}
              </td>
              <td width="120px" align="right">来样染色：</td>
              <td width="260px" align="left">
                {{ defaultText(productBillInfo.laiyang, 2) }}
              </td>
                            <td width="120px" align="right">附加棱镜：</td>
              <td width="260px" align="left">
                {{ defaultText(productBillInfo.lengjing, 2) }}
              </td>
            </tr>
            <tr bgcolor="#FFFFFF" height="28px">

              <td width="120px" align="right">等像镜：</td>
              <td width="260px" align="left">
                {{ defaultText(productBillInfo.dengxiangjing, 2) }}
              </td>
              <td width="120px" align="right">超光度：</td>
              <td width="260px" align="left">
                {{ defaultText(productBillInfo.chaoguangdu, 2) }}
              </td>
            </tr>
            <!-- <tr bgcolor="#FFFFFF" height="28px">
              <td width="120px" align="right">半成品基弯：</td>
              <td width="260px" align="left"></td>
              <td width="120px" align="right">厚度：</td>
              <td width="260px" align="left"></td>
            </tr>
            <tr bgcolor="#FFFFFF" height="28px">
              <td width="120px" align="right">半成品基弯：</td>
              <td width="260px" align="left"></td>
              <td width="100px" align="right">厚度：</td>
              <td width="260px" align="left"></td>
            </tr> -->
          </table>
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  queryPageByParam,
  getOrder,
  delOrder,
  addOrder,
  updateOrder,
  queryById,
  showPatternList,
  shengchandan,
} from "@/api/order/order.js";

import { showOrderAddress } from "@/api/order/address.js";
import { showOrderExpress } from "@/api/order/express.js";
import { queryListByParam } from "@/api/bank/payment.js";
import { queryPageByParam as queryJiajiList } from "@/api/base/process.js";
import { formatDate } from "@/utils/date";
import { getCurrentInstance } from "vue";
import useUserStore from "@/store/modules/user";
import { listDept } from "@/api/system/dept";
import { getDataByChildDictType } from "@/api/system/dict/data";
export default {
  setup() {
    // 获取当前组件实例
    const instance = getCurrentInstance();
    const { order_status } = instance.proxy.useDict("order_status");
    const { order_payment_status } = instance.proxy.useDict(
      "order_payment_status"
    );
    const { order_express_status } = instance.proxy.useDict(
      "order_express_status"
    );
    const { order_jiaji_status } = instance.proxy.useDict("order_jiaji_status");
    const { order_export_status } = instance.proxy.useDict(
      "order_export_status"
    );

    return {
      order_status,
      order_payment_status,
      order_express_status,
      order_jiaji_status,
      order_export_status,
    };
  },
  name: "OrderMessage",
  data() {
    return {
      value2: "",
      defaultTime: [
        new Date(2023, 2, 1, 0, 0, 0, 0),
        new Date(2023, 2, 5, 23, 59, 59, 0),
      ],
      defaultDeptId: null,
      deptList: [],
      isManage: false,
      productBillInfo: null,
      isShowProduceBill: false,
      productName: null,
      rightQuantity: null,
      leftQuantity: null,
      patternOneLeftList: [],
      patternOneRightList: [],
      orderPatternList: [],
      orderExpressList: [],
      orderAddressList: [],
      orderId: null,
      companyId: null,
      paymentList: [],
      activeName: "first",
      productList: [],
      orderAllInfo: {},
      companyAllInfo: "",
      isDetail: true,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 表格数据
      orderList: [],
      columns: [{ key: 0, label: "商品名称", visible: true }],
      jiajiList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        orderIds: null,
        pageNum: 1,
        pageSize: 10,
        isExport: "true",
        createTimes: ["", ""],
        beginCreateTime: "",
        endCreateTime: "",
        beginPayTime: "",
        endPayTime: "",
        payedTimes: ["", ""],
        orderExpressCreateTimes: ["", ""],
        orderExpressBeginCreateTime: "",
        orderExpressEndCreateTime: "",
        companyId: null,
        orderNo: null,
        orderObject: null,
        orderObjectId: null,
        orderTramNo: null,
        orderType: null,
        sellerId: null,
        fenSellerId: null,
        buyerId: null,
        settlePay: null,
        orderUserPay: null,
        orderPay: null,
        oughtPay: null,
        actualPay: null,
        refundPay: null,
        couponPay: null,
        adjustPay: null,
        compensationPay: null,
        gongyiStatus: null,
        gongyiPay: null,
        ranseStatus: null,
        ransePay: null,
        ranseType: null,
        ranseNo: null,
        keziName: null,
        jiagongStatus: null,
        jiagongPay: null,
        jiagongMemo: null,
        meiboStatus: null,
        meiboPay: null,
        jiajiStatus: null,
        jiajiPay: null,
        jiajiId: null,
        expressId: null,
        expressPay: null,
        bianseId: null,
        bianseName: null,
        bianseColor: null,
        biansePay: null,
        orderStatus: null,
        paymentStatus: null,
        expressStatus: null,
        refundStatus: null,
        hexiaoStatus: null,
        paymentTarget: null,
        paymentType: null,
        expressType: null,
        paymentChannel: null,
        orderChannel: null,
        orderChannelUserName: null,
        orderChannelNo: null,
        orderChannelUserId: null,
        orderChannelMobile: null,
        orderChannelUserCode: null,
        createTime: null,
        MEMO: null,
        buyNumber: null,
        buyLeftNumber: null,
        buyRightNumber: null,
        payedTime: null,
        overTime: null,
        completeTime: null,
        refundTime: null,
        refundUserId: null,
        cancelTime: null,
        cancelMemo: null,
        expressTime: null,
        pointStatus: null,
        pointTime: null,
        remoteStatus: null,
        settleStatus: null,
        settleTime: null,
        detailStatus: null,
        detailTime: null,
        createEmployeeId: null,
        exportStatus: null,
        exportTime: null,
        exportEmployeeId: null,
        fahuoStatus: null,
        fahuoTime: null,
        fahuoEmployeeId: null,
        deptId: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
    };
  },

  watch: {
    "queryParams.orderExpressCreateTimes"(newVal) {
      if (newVal == null) {
        this.queryParams.orderExpressCreateTimes = ["", ""];
      }
    },
    "queryParams.payedTimes"(newVal) {
      if (newVal == null) {
        this.queryParams.payedTimes = ["", ""];
      }
    },
    "queryParams.createTimes"(newVal) {
      if (newVal == null) {
        this.queryParams.createTimes = ["", ""];
      }
    },
  },
  created() {
    const roles = useUserStore().roles;
    var filteredArr = roles.filter(
      (item) => item !== "manage" && item !== "salesman"
    );
    if (filteredArr.length > 0) {
      this.isManage = true;
    } else {
      this.isManage = false;
    }
    var filterPriceArr = roles.filter(
      (item) => item === "admin" || item === "priceshow"
    );
    if (filterPriceArr.length > 0) {
      this.columns.push(
        { key: 1, label: "订单金额", visible: false },
        { key: 2, label: "应付金额", visible: false },
        { key: 3, label: "实收金额", visible: false }
      );
    }
    // var date1 = new Date('2024-08-14T00:00:00Z');
    // var date2 = new Date('2024-08-14T23:59:59Z');
    // this.queryParams.createTimes[0] = date1;
    // this.queryParams.createTimes[1] = date2;
    this.getDataByChildDictType();
    this.getList();
    this.queryJiajiList();
  },
  methods: {
    getDataByChildDictType() {
      const dictValue = "mange_dept_id_key";
      getDataByChildDictType(dictValue).then((response) => {
        this.defaultDeptId = response.data.dictLabel;
        this.getlistDept(this.defaultDeptId);
      });
    },

    /** 查询部门列表 */
    getlistDept(defaultDeptId) {
      const queryDeptListParams = {
        parentId: defaultDeptId,
      };

      listDept(queryDeptListParams).then((response) => {
        this.deptList = response.data;
      });
    },
    convertFenToYuan(fen) {
      const fenFen = (fen / 100).toFixed(2); // 小数部分，保留分（到小数点后两位）
      return fenFen;
    },
    defaultText(text, type = 1) {
      if (text) return text;
      else return type == 1 ? "否" : "无";
    },
    isCheckboxDisabled(row) {
      // 根据行数据的状态字段来决定是否禁用勾选框
      return row.exportStatus === "FALSE";
    },
    /** 导出生产单操作 */
    handleProductExport() {
      const oldQueryParams = { ...this.queryParams };
      if (this.ids !== null && this.ids.length > 0) {
        this.queryParams.orderIds = this.ids.join(", ");
      }

      this.download(
        "yanjing/order/handleProductExport",
        {
          ...this.queryParams,
        },
        `order_${new Date().getTime()}.xlsx`
      );
      this.queryParams = oldQueryParams;
      this.getList();
    },
    //打印页面内容
    printTable() {
      // 获取要打印的内容
      let wpt = document.querySelector("#printTest");
      if (!wpt) return; // 如果没有找到指定的元素，直接返回
      // 创建一个 iframe 作为打印容器
      let printFrame = document.createElement("iframe");
      printFrame.style.position = "absolute";
      printFrame.style.width = "0px";
      printFrame.style.height = "0px";
      printFrame.style.border = "none";
      document.body.appendChild(printFrame);
      // 将要打印的内容写入 iframe
      let frameDocument = printFrame.contentWindow.document;
      frameDocument.open();
      frameDocument.write(`
    <html>
      <head>
        <title>打印</title>
        <style>
          /* 将你的样式复制到打印页面 */
          @media print {
            @page {
              margin-top: 0;
              margin-bottom: 0;
            }
            body {
              padding-top: 100px;
              padding-bottom: 0;
            }
          }
          body {
            font-family: Arial, sans-serif;
          }
        </style>
      </head>
      <body>
        ${wpt.innerHTML}
      </body>
    </html>
  `);
      frameDocument.close();
      // 调用打印
      printFrame.contentWindow.focus();
      printFrame.contentWindow.print();
      // 打印后移除 iframe
      printFrame.addEventListener("afterprint", () => {
        document.body.removeChild(printFrame);
      });
      // 为了兼容不支持 afterprint 事件的浏览器，设置延时移除 iframe
      setTimeout(() => {
        if (document.body.contains(printFrame)) {
          document.body.removeChild(printFrame);
        }
      }, 1000);
    },
    handleTabClick(tab, event) {
      if ("0" === tab.index) {
        //获取支付记录
        // this.queryListByParam();
      } else if ("1" === tab.index) {
        //获取收货地址
        console.log("Tab clicked:", tab.index);
      } else if ("2" === tab.index) {
        //获取物流信息
        console.log("Tab clicked:", tab.index);
      } else if ("3" === tab.index) {
        //获取左右眼参数
        console.log("Tab clicked:", tab.index);
      }
    },
    queryListByParam(orderId) {
      return new Promise((resolve) => {
        const param = {
          object: "ORDER",
          objectId: orderId,
        };
        queryListByParam(param).then((response) => {
          if (response.code === 200) {
            resolve(response.rows);
          }
        });
      });
    },

    showOrderExpress(orderId, companyId) {
      return new Promise((resolve) => {
        const param = {
          object: "ORDER",
          objectId: orderId,
          companyId: companyId,
        };
        showOrderExpress(param).then((response) => {
          if (response.code === 200) {
            resolve(response.rows);
          }
        });
      });
    },
    showOrderAddress(orderId, orderNo) {
      return new Promise((resolve) => {
        const param = {
          orderNo: orderNo,
          orderId: orderId,
        };
        showOrderAddress(param).then((response) => {
          if (response.code === 200) {
            resolve(response.rows);
          }
        });
      });
    },
    showPatternList(orderId, orderNo) {
      return new Promise((resolve) => {
        const param = {
          orderNo: orderNo,
          orderId: orderId,
        };
        showPatternList(param).then((response) => {
          if (response.code === 200) {
            resolve(response.rows);
          }
        });
      });
    },
    async refreshExpressInfo() {
      this.orderExpressList = await this.showOrderExpress(
        this.orderId,
        this.companyId
      );
    },

    queryById(orderId) {
      return new Promise((resolve) => {
        queryById(orderId).then((response) => {
          if (response.code === 200) {
            resolve(response.data);
          }
        });
      });
    },
    shengchandan(orderId) {
      return new Promise((resolve) => {
        shengchandan(orderId).then((response) => {
          if (response.code === 200) {
            resolve(response.data);
          }
        });
      });
    },
    // shengchandan(orderId){
    //   shengchandan(orderId).then((response) => {
    //     this.productBillInfo = response.data;
    //   });
    // },
    async showProduceBill(row) {
      this.productBillInfo = await this.shengchandan(row.orderId);
      this.isShowProduceBill = true;
    },

    async handleView(row) {
      this.orderId = row.orderId;
      this.companyId = row.companyId;
      this.orderAllInfo = await this.queryById(row.orderId);

      this.paymentList = await this.queryListByParam(row.orderId);
      this.orderAddressList = await this.showOrderAddress(
        row.orderId,
        row.orderNo
      );
      this.orderExpressList = await this.showOrderExpress(
        row.orderId,
        row.companyId
      );
      this.orderPatternList = await this.showPatternList(
        row.orderId,
        row.orderNo
      );
      if (
        this.orderPatternList !== null &&
        this.orderPatternList !== undefined &&
        this.orderPatternList.length > 0
      ) {
        var row = this.orderPatternList[0];
        this.leftQuantity = row.leftQuantity;
        this.rightQuantity = row.rightQuantity;
        this.patternOneLeftList = row.patternOneLeftList;
        this.patternOneRightList = row.patternOneRightList;
        this.productName = row.productName;
      }

      this.productList = this.orderAllInfo.products;
      //判读是否特殊工艺：按样染色、等像镜、刻字、来样染色、超光度、附加棱镜、蓝光
      if (
        this.orderAllInfo.ranseStatusZh == "是" ||
        this.orderAllInfo.bianseColor == "是" ||
        this.orderAllInfo.lengjingPayYuan != "0.00" ||
        this.orderAllInfo.laiyangPayYuan != "0.00" ||
        this.orderAllInfo.dengxiangPayYuan != "0.00" ||
        this.orderAllInfo.chaoguangduPayYuan != "0.00" ||
        this.orderAllInfo.keziPayYuan != "0.00"
      ) {
        this.orderAllInfo.teshuStatusZh = "是";
        var teshuPay =
          this.orderAllInfo.lengjingPay == null
            ? 0
            : this.orderAllInfo.lengjingPay +
              (this.orderAllInfo.laiyangPay == null
                ? 0
                : this.orderAllInfo.laiyangPay) +
              (this.orderAllInfo.dengxiangPay == null
                ? 0
                : this.orderAllInfo.dengxiangPay) +
              (this.orderAllInfo.chaoguangduPay == null
                ? 0
                : this.orderAllInfo.chaoguangduPay) +
              (this.orderAllInfo.keziPay == null
                ? 0
                : this.orderAllInfo.keziPay) +
              (this.orderAllInfo.ransePay == null
                ? 0
                : this.orderAllInfo.ransePay) +
              (this.orderAllInfo.biansePay == null
                ? 0
                : this.orderAllInfo.biansePay);
        this.orderAllInfo.teshuPayYuan = this.convertFenToYuan(teshuPay);
      } else {
        this.orderAllInfo.teshuPayYuan = "0.00";
        this.orderAllInfo.teshuStatusZh = "否";
      }
      // this.orderAddressList = this.orderAllInfo.orderAddressList;
      // this.orderExpressList = this.orderAllInfo.orderExpressList;
      if (this.orderAllInfo.teshuPayYuan == "0.00") {
        this.orderAllInfo.teshuPayYuan = "";
      }
      if (this.orderAllInfo.lengjingPayYuan == "0.00") {
        this.orderAllInfo.lengjingPayYuan = "";
      }
      if (this.orderAllInfo.laiyangPayYuan == "0.00") {
        this.orderAllInfo.laiyangPayYuan = "";
      }

      if (this.orderAllInfo.dengxiangPayYuan == "0.00") {
        this.orderAllInfo.dengxiangPayYuan = "";
      }

      if (this.orderAllInfo.chaoguangduPayYuan == "0.00") {
        this.orderAllInfo.chaoguangduPayYuan = "";
      }
      if (this.orderAllInfo.keziPayYuan == "0.00") {
        this.orderAllInfo.keziPayYuan = "";
      }
      if (this.orderAllInfo.refundPayYuan == "0.00") {
        this.orderAllInfo.refundPayYuan = "";
      }
      if (this.orderAllInfo.jiagongPayYuan == "0.00") {
        this.orderAllInfo.jiagongPayYuan = "";
      }
      if (this.orderAllInfo.meiboPayYuan == "0.00") {
        this.orderAllInfo.meiboPayYuan = "";
      }
      if (this.orderAllInfo.jiajiPayYuan == "0.00") {
        this.orderAllInfo.jiajiPayYuan = "";
      }
      if (this.orderAllInfo.ransePayYuan == "0.00") {
        this.orderAllInfo.ransePayYuan = "";
      }
      if (this.orderAllInfo.biansePayYuan == "0.00") {
        this.orderAllInfo.biansePayYuan = "";
      }

      this.form = { ...this.orderAllInfo };

      this.open = true;
      this.isDetail = false;
      this.title = "订单详情";
      this.companyAllInfo =
        "客户订单编号【" +
        this.form.orderChannelNo +
        "】" +
        "客户编号【" +
        this.form.companyCode +
        "】" +
        "客户简称【" +
        this.form.companyName +
        "】" +
        "客户全称【" +
        this.form.fullName +
        "】";
      // this.form.approveMemo =
      //   this.form.approveMemo == null ? "审核" : this.form.approveMemo;
    },
    /** 查询列表 */
    getList() {
      this.loading = true;
      this.queryParams.beginCreateTime =
        this.queryParams.createTimes[0] === ""
          ? this.queryParams.createTimes[0]
          : formatDate(this.queryParams.createTimes[0], "yyyy-MM-dd hh:mm:ss");
      this.queryParams.endCreateTime =
        this.queryParams.createTimes[1] === ""
          ? this.queryParams.createTimes[1]
          : formatDate(this.queryParams.createTimes[1], "yyyy-MM-dd hh:mm:ss");

      this.queryParams.beginPayTime =
        this.queryParams.payedTimes[0] === ""
          ? this.queryParams.payedTimes[0]
          : formatDate(this.queryParams.payedTimes[0], "yyyy-MM-dd hh:mm:ss");
      this.queryParams.endPayTime =
        this.queryParams.payedTimes[1] === ""
          ? this.queryParams.payedTimes[1]
          : formatDate(this.queryParams.payedTimes[1], "yyyy-MM-dd hh:mm:ss");

      this.queryParams.orderExpressBeginCreateTime =
        this.queryParams.orderExpressCreateTimes[0] === ""
          ? this.queryParams.orderExpressCreateTimes[0]
          : formatDate(
              this.queryParams.orderExpressCreateTimes[0],
              "yyyy-MM-dd hh:mm:ss"
            );
      this.queryParams.orderExpressEndCreateTime =
        this.queryParams.orderExpressCreateTimes[1] === ""
          ? this.queryParams.orderExpressCreateTimes[1]
          : formatDate(
              this.queryParams.orderExpressCreateTimes[1],
              "yyyy-MM-dd hh:mm:ss"
            );

      queryPageByParam(this.queryParams).then((response) => {
        this.orderList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    queryJiajiList() {
      this.loading = true;
      var quejiajiform = {
        pageNum: 1,
        pageSize: 10,
        type: "JIAJI",
      };
      queryJiajiList(quejiajiform).then((response) => {
        this.jiajiList = response.rows;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        orderId: null,
        companyId: null,
        orderNo: null,
        orderObject: null,
        orderObjectId: null,
        orderTramNo: null,
        orderType: null,
        sellerId: null,
        fenSellerId: null,
        buyerId: null,
        settlePay: null,
        orderUserPay: null,
        orderPay: null,
        oughtPay: null,
        actualPay: null,
        refundPay: null,
        couponPay: null,
        adjustPay: null,
        compensationPay: null,
        gongyiStatus: null,
        gongyiPay: null,
        ranseStatus: null,
        ransePay: null,
        ranseType: null,
        ranseNo: null,
        keziName: null,
        jiagongStatus: null,
        jiagongPay: null,
        jiagongMemo: null,
        meiboStatus: null,
        meiboPay: null,
        jiajiStatus: null,
        jiajiPay: null,
        jiajiId: null,
        expressId: null,
        expressPay: null,
        bianseId: null,
        bianseName: null,
        bianseColor: null,
        biansePay: null,
        orderStatus: null,
        paymentStatus: null,
        expressStatus: null,
        refundStatus: null,
        hexiaoStatus: null,
        paymentTarget: null,
        paymentType: null,
        expressType: null,
        paymentChannel: null,
        orderChannel: null,
        orderChannelUserName: null,
        orderChannelNo: null,
        orderChannelUserId: null,
        orderChannelMobile: null,
        orderChannelUserCode: null,
        createTime: null,
        MEMO: null,
        buyNumber: null,
        buyLeftNumber: null,
        buyRightNumber: null,
        payedTime: null,
        overTime: null,
        completeTime: null,
        refundTime: null,
        refundUserId: null,
        cancelTime: null,
        cancelMemo: null,
        expressTime: null,
        pointStatus: null,
        pointTime: null,
        remoteStatus: null,
        settleStatus: null,
        settleTime: null,
        detailStatus: null,
        detailTime: null,
        createEmployeeId: null,
        exportStatus: null,
        exportTime: null,
        exportEmployeeId: null,
        fahuoStatus: null,
        fahuoTime: null,
        fahuoEmployeeId: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.orderId);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const orderId = row.orderId || this.ids;
      getOrder(orderId).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "修改";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.orderId != null) {
            updateOrder(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addOrder(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const orderIds = row.orderId || this.ids;
      this.$modal
        .confirm('是否确认删除编号为"' + orderIds + '"的数据项？')
        .then(function () {
          return delOrder(orderIds);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "yanjing/order/export",
        {
          ...this.queryParams,
        },
        `order_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>

<style>
@media print {
  @page {
    margin-top: 0;
    margin-bottom: 0;
  }
  body {
    padding-top: 100px;
    padding-bottom: 0;
  }
}
</style>